package com.flybear.aqi.client;

/**
 * Internal ElasticSearch client factory. Responsible for creating instance
 * of ElasticSearch clients.
 */
public class ElasticSearchClientFactory {
  public static final String HighLevelRestClient = "highlevel";

  /**
   * @param clientType  String representation of client type
   * @param hostNames   Array of strings that represents hostnames with ports (hostname:port)
   * @param clusterName Elasticsearch cluster name used only by Transport Client
   * @param serializer  Serializer of flume events to elasticsearch documents
   * @return
   */
  public ElasticSearchClient getClient(String clientType, String[] hostNames,
                                       String clusterName, ElasticSearchEventSerializer serializer,
                                       ElasticSearchIndexRequestBuilderFactory indexBuilder) throws NoSuchClientTypeException {
//    if (clientType.equalsIgnoreCase(TransportClient) && serializer != null) {
//      return new ElasticSearchTransportClient(hostNames, clusterName, serializer);
//    } else if (clientType.equalsIgnoreCase(TransportClient) && indexBuilder != null) {
//      return new ElasticSearchTransportClient(hostNames, clusterName, indexBuilder);
//    } else
    if (clientType.equalsIgnoreCase(HighLevelRestClient) ) {
      if(indexBuilder != null)return new ElasticSearchHighLevelClient(hostNames, clusterName, indexBuilder);
      return new ElasticSearchHighLevelClient(hostNames, clusterName, serializer);
    }
    throw new NoSuchClientTypeException();
  }


}
